package com.diaohw.module.system.mapper;

import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.diaohw.module.system.obj.entity.Role;
import com.diaohw.module.system.obj.query.RoleQuery;
import com.diaohw.module.system.obj.tables.RoleDef;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
/**
 * 角色 映射层。
 *
 * @author D-Hw
 * @since 2024-11-15 18:22:15
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {


    static QueryWrapper createWrapper(RoleQuery query){
       QueryWrapper wrapper = QueryWrapper.create();
       wrapper.and(RoleDef.ROLE.STATE.eq(query.getState()).when(ObjUtil.isNotNull(query.getState())));
       wrapper.and(RoleDef.ROLE.ROLE_CODE.eq(query.getRoleCode()).when(StrUtil.isNotBlank(query.getRoleCode())));
       wrapper.and(RoleDef.ROLE.ROLE_NAME.eq(query.getRoleName()).when(StrUtil.isNotBlank(query.getRoleName())));
       wrapper.and(RoleDef.ROLE.ROLE_TYPE.eq(query.getRoleType()).when(ObjUtil.isNotNull(query.getRoleType())));
       return wrapper;
   }
}
